package com.yanqu.road.entity.activity.hsisland.config;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.RandomHelper;

import java.math.BigDecimal;
import java.math.RoundingMode;

@FieldTypeAnnotation(tableName = "t_s_activity_hsisland_pve")
public class HsIslandPveConfig {

    @FieldTypeAnnotation(desc = "活动id", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "ID", select = true, update = true)
    private int id;

    @FieldTypeAnnotation(desc = "类型,1:pve小怪，2：大pve怪，3：圣柱BOSS")
    private int type;

    @FieldTypeAnnotation(desc = "形象id")
    private String appearanceId;

    @FieldTypeAnnotation(desc = "名称")
    private String name;

    @FieldTypeAnnotation(desc = "描述")
    private String desc;

    @FieldTypeAnnotation(desc = "页签")
    private int tab;

    @FieldTypeAnnotation(desc = "头衔")
    private String title;

    @FieldTypeAnnotation(desc = "对话文本")
    private String talkText;

    @FieldTypeAnnotation(desc = "血量")
    private String hp;

    @FieldTypeAnnotation(desc = "品质")
    private int quality;

    @FieldTypeAnnotation(desc = "奖励")
    private String reward;

    @FieldTypeAnnotation(desc = "积分")
    private int score;

    @FieldTypeAnnotation(desc = "可邀请人数")
    private int canInviteNum;

    @FieldTypeAnnotation(desc = "权重")
    private int weight;

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getAppearanceId() {
        return appearanceId;
    }

    public void setAppearanceId(String appearanceId) {
        this.appearanceId = appearanceId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public int getTab() {
        return tab;
    }

    public void setTab(int tab) {
        this.tab = tab;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getHp() {
        return hp;
    }

    public void setHp(String hp) {
        this.hp = hp;
    }

    public int getQuality() {
        return quality;
    }

    public void setQuality(int quality) {
        this.quality = quality;
    }

    public String getReward() {
        return reward;
    }

    public void setReward(String reward) {
        this.reward = reward;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }

    public int getCanInviteNum() {
        return canInviteNum;
    }

    public void setCanInviteNum(int canInviteNum) {
        this.canInviteNum = canInviteNum;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTalkText() {
        return talkText;
    }

    public void setTalkText(String talkText) {
        this.talkText = talkText;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    /**
     * 获取怪物血量
     * @param aveOpenDay
     * @return
     */
    public long getMonsterBlood(int aveOpenDay) {
        String[] hpArr = this.hp.split("#");
        String param1 = hpArr[0];
        String param2 = hpArr[1];
        String[] param1Arr =param1.split(";");
        long targetHp = 0;
        for (String openDayHp : param1Arr) {
            String[] openDayHpArr = openDayHp.split(",");
            int openDay = Integer.parseInt(openDayHpArr[0]);
            long hp = Long.parseLong(openDayHpArr[1]);
            if (aveOpenDay >= openDay) {
                targetHp = hp;
            }
        }
        //乘上浮动比例
        int startRate = Integer.parseInt(param2.split("\\|")[0]);
        int endRate = Integer.parseInt(param2.split("\\|")[1]);
        RandomHelper randomHelper = new RandomHelper();
        int rate = randomHelper.next(startRate, endRate + 1);
        return BigDecimal.valueOf(targetHp).multiply(BigDecimal.valueOf(rate).divide(BigDecimal.valueOf(1000), 8,  RoundingMode.UP)).setScale(0, RoundingMode.CEILING).longValue();
    }
}
